package async.supplyAsync;

import java.util.concurrent.*;

public class Demo1 {
    public static void main(String[] args) {
        ExecutorService executor = Executors.newFixedThreadPool(100);
        CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {
            try {
                TimeUnit.SECONDS.sleep(3);
                System.out.println("child run");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return 123;
        }, executor);
        System.out.println("main end");
        try {
            Integer integer = future.get();
            System.out.println(integer);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        executor.shutdown();
    }
}
